import { Toast } from "antd-mobile"
import { useEffect, useRef } from "react"

function useToken() {
  const timer = useRef(null)
  const token = localStorage.getItem("token")
  console.log(token)
  // token过期时间
  timer.current = setInterval(() => {
    localStorage.clear()
    if (!token) {
      Toast.show("请重新登录")
    }
  }, 3000 * 10)
  useEffect(() => {
    return () => {
      clearInterval(timer.current)
    }
  })
  return token
}

export default useToken
